package otherapi;

import com.alibaba.fastjson.JSON;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class CollectionUtilsTest {


    private static final Logger logger = LoggerFactory.getLogger(CollectionUtilsTest.class);

    @Test
    public void unionSubTest() {
        List<String> list1 = new ArrayList<>();
        list1.add("a");
        list1.add("b");
        list1.add("c");
        List<String> list2 = new ArrayList<>();
        list2.add("a");
        list2.add("d");
        list2.add("e");
        Collection<String> union = CollectionUtils.union(list1, list2);
        // 新增
        Collection<String> addTable = CollectionUtils.subtract(union, list1);
        // 减少
        Collection<String> subTable = CollectionUtils.subtract(list1, list2);
        logger.info("=======>增加 {}", JSON.toJSON(addTable));
        logger.info("=======>减少 {}", JSON.toJSON(subTable));
    }

}